﻿using System;
using System.Collections.Generic;
using System.Text;
using StackExchange.Redis;

namespace Vabp.Infrastructure.Redis
{
    public class RedisTest
    {
        public static ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost");

        public void RedisUseTest()
        {
//            IDatabase db = redis.GetDatabase();

//            string setValue = "abcdefg";
//            db.StringSet("mykey", setValue);
//
//            string getValue = db.StringGet("mykey");
//            Console.WriteLine(getValue); // writes: "abcdefg"

            ISubscriber subscriber = redis.GetSubscriber();

            subscriber.Subscribe("message", (channel, message) =>
            {
                Console.WriteLine(message);

            });

            subscriber.Publish("message", "Hello,World!");

        }
    }
}
